/* 
 * Copyright (C) 2015 fede
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package Entity;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;

/**
 *
 * @author fede
 */
@Entity
@NamedQueries({
    @NamedQuery(name = NotifyReply.FIND_ALL, query = "SELECT n FROM NotifyReply n WHERE n.event.id = :eventId AND n.user.email= :user"),
    @NamedQuery(name = NotifyReply.FIND_ALL_EVENT, query = "SELECT n FROM NotifyReply n WHERE n.event.id = :eventId"),
    @NamedQuery(name = NotifyReply.FIND_ALL_FOR_USER, query = "SELECT n FROM NotifyReply n WHERE n.user.email= :user"),})
public class NotifyReply implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private String message;
    private Boolean reply;

    //association with RegisteredUser
    @OneToOne
    private RegisteredUser user;

    //association with Event
    @OneToOne
    private Event event;

    /**
     * find all notify
     */
    public static final String FIND_ALL = "NotifyReply.findAll";

    /**
     * find all notify for user
     */
    public static final String FIND_ALL_FOR_USER = "NotifyReply.findAllForUser";

    /**
     * find all notify for event
     */
    public static final String FIND_ALL_EVENT = "NotifyReply.findAllEvent";

    /**
     * this method get the Event of notify
     *
     * @return Event
     */
    public Event getEvent() {
        return event;
    }

    /**
     * this method set the Event of notify
     *
     * @param event of notify
     */
    public void setEvent(Event event) {
        this.event = event;
    }

    /**
     * this method get the RegisteredUser of notify
     *
     * @return RegisteredUser
     */
    public RegisteredUser getUser() {
        return user;
    }

    /**
     * this method get the RegisteredUser of notify
     *
     * @param user RegistereUser
     */
    public void setUser(RegisteredUser user) {
        this.user = user;
    }

    /**
     * this method get the Message of notify
     *
     * @return message as String
     */
    public String getMessage() {
        return message;
    }

    /**
     * this method set the Messaga of notify
     *
     * @param message as String
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * this method get the Reply of notify
     *
     * @return boolean reply
     */
    public Boolean getReply() {
        return reply;
    }

    /**
     * this method get the Reply of notify
     *
     * @param reply NotifyReply
     */
    public void setReply(Boolean reply) {
        this.reply = reply;
    }

    /**
     * this method get the Id of notify
     *
     * @return Id as Long
     */
    public Long getId() {
        return id;
    }

    /**
     * this method set the Id of notify
     *
     * @param id Id as Long
     */
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof NotifyReply)) {
            return false;
        }
        NotifyReply other = (NotifyReply) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.NotifyReply[ id=" + id + " ]";
    }

}
